<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%><!DOCTYPE HTML>
<html>
<head>
<title>用户管理</title>
<script type="text/javascript">

	$(function() {
		$('#toolbar').toolbar({buttons:[
		    {name:'search',iconCls:'icon-search',text:'检索'},
           	{name:'add',iconCls:'icon-add',text:'添加模块'},
       		{name:'edit',iconCls:'icon-edit',text:'修改',disabled:true},
       		{name:'del',iconCls:'icon-del',text:'删除',disabled:true}
      	],handler:handler});
		$('#grid').datagrid({url: 'page',title:'模块列表',pagination:true,singleSelect:true,rownumbers:true,striped:true,fitColumns:true,
			columns:[[
			{field:'modelName',title:'模块名称'},
			{field:'modelDes',title:'模块描述'},
			{field:'permCode',title:'权限编码'},
			{field:'permType',title:'权限类型'},
			{field:'permName',title:'权限名称'},
			{field:'level',title:'级别'},
			{field:'isOpen',title:'是否开放',formatter:$g.bv},
			{field:'enabled',title:'启用标记',formatter:$g.bv}
			]]
			,onClickRow:function(i,r) {
				$('#toolbar').toolbar('enableAll');
			}
			,onBeforeLoad:function(param) {
				$('#toolbar').toolbar('search,add,add2');
			}
		});
		
	});

	function handler() {
		if(this.name == 'search') return toSearch();
		if(this.name == 'add') return toAdd();
		var item = $('#grid').datagrid('getSelected');
		if(!item) return;
		switch(this.name) {
		case 'addSub': toAddSub(item);break;
		case 'edit': toEdit(item);break;
		case 'del': toDel(item);break;
		}
	}
	
	function toSearch() {
		$('#grid').datagrid('load',$('#qform').serializeArray());
	}
	
	function toAdd() {
		show({code:'admin_model_index',title:'添加模块',iconCls:'icon-add',uri:'add',width:800,height:600,
			options : {
				success : function(data) { 
					$('#grid').datagrid('reload'); 
				}
			}
		});
	}

	function toEdit(item) {
		show({code:'admin_model_index',title:'编辑功能模块',iconCls:'icon-add',uri:'edit?id='+item.id,width:800,height:600,
			options : {
				success : function(data) { 
					$('#grid').datagrid('reload'); 
				}
			}
		});
	}
	
	function toDel(item) {
		$confirm('您确定要删除“'+item.username+'”模块信息吗？',function() {
			$.post('delete?id='+item.id,function(r) {
				if(r.code <= 0) return $error(r.msg);
				$('#grid').datagrid('reload');
				$prompt('删除成功');
			},'json');
		});
	}

	
	function doSave() {
		$.submit('#dataform',function(r) {
			if(r.code<0) return $alert(r.msg);
			$('#dialog').dialog('close');
			$('#grid').datagrid('reload');
			$prompt('保存成功');
		});
	}


</script>
</head>
<body class="easyui-layout">
	<div data-options="region:'north',border:false" style="height:90px;">
		<div id="toolbar" class="toolbar"></div>
		<form id="qform">
			<table class="form-tbl">
				<tr class="form-tr">
					<th class="form-th">模块名称：</th>
					<td class="form-td" style="width: 130px" >
						<input type="text" name="modelName" class="form-text" style="width: 120px" />
					</td>
					<td></td>
				</tr>
			</table>
		</form>
	</div>
	<div data-options="region:'center',border:false">
		<table id="grid"></table>
	</div>
</body>
</html>